
def showpages(count,p):
    # count 总页数
    # p 当前页码数

    # 每回显示10个页码数

    # begin = p-4
    # end = p+5

    # 总页码数不到10页
    if count < 10:
        begin = 1
        end = count
    # 当前页码数加5小于等于10页
    elif p + 5 <= count:
        # 当前页码数小于等于5
        if p <= 5:
            begin = 1
            end = 10
        # 当前页码数大于5
        if p > 5:
            begin = p - 4
            end = p + 5
    # 当前页码数加5大于10页
    elif p + 5 > count:
        begin = count - 9
        end = count

    for i in range(begin,end+1):
        print(i ,end=' ')
    




showpages(9,8)
print('')
showpages(100,20)
print('')
showpages(100,3)
print('')
showpages(100,96)